package com.itheima07;

import java.util.Calendar;

/**
 * @author Xiao
 * @date 2021/7/13
 */
public class CalendarDemo {
    /**
     * API_Calendar
     */
    public static void main(String[] args) {
        //Calendar rightNow = Calendar.getInstance();
        Calendar c = Calendar.getInstance();    //多态
        System.out.println(c);
        System.out.println("------");
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH) + 1; //月份默认从0开始，获取所需月份需要在表达式后+1
        int hour = c.get(Calendar.HOUR);
        int minute = c.get(Calendar.MINUTE);
        int second = c.get(Calendar.SECOND);
        System.out.println(year + "年" + month + "月" + day + "日");
        System.out.println(hour + ":" + minute + ":" + second);
    }
}
